﻿using System;
using Company.IO.Interfaces;
using Company.System.IO.IntegrationTests.Properties;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Company.System.IO.IntegrationTests
{
    public partial class DirectoryTest : TestBase<IDirectory>
    {
        private const string _SEnumerateFilesMethodName = "EnumerateFiles";

        [TestMethod]
        public void EnumerateFiles_PathNull_ArgumentNullException()
        {
            PathNull_ArgumentNullException(_SEnumerateFilesMethodName);
        }

        [TestMethod]
        public void EnumerateFiles_PathNullSearchPatternNull_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(SStringNull, SStringNull);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathNullSearchPatternNullSearchOptionAllDirectories_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(SStringNull, SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathValidSearchPatternNull_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(_SEnumerateFilesMethodName, SStringNull);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathValidSearchPatternNullSearchOptionAllDirectories_ArgumentNullException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(_SEnumerateFilesMethodName, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentNullException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathEmpty_ArgumentException()
        {
            PathEmpty_ArgumentException(_SEnumerateFilesMethodName);
        }

        [TestMethod]
        public void EnumerateFiles_PathEmptySearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(string.Empty, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathEmptySearchPatternNullSearchOptionAllDirectories_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(string.Empty, SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisOnlyWhitespace_ArgumentException()
        {
            PathContaisOnlyWhitespace_ArgumentException(_SEnumerateFilesMethodName);
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisOnlyWhitespaceSearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyWhitspace, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFiles_PathContaisOnlyWhitespaceSearchPatternNullSearchOptionAllDirectories_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyWhitspace, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisOnlyColonChar_ArgumentException()
        {
            PathContaisOnlyColonChar_ArgumentException(_SEnumerateFilesMethodName);
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisOnlyColonCharSearchPatternNull_ArgumentException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyColonChar, SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisOnlyColonCharSearchPatternNullSearchOptionAllDirectories_ArgumentException
            ()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathContainsOnlyColonChar, SStringNull,
                                                     SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisInvalidPathChar_ArgumentException()
        {
            PathContaisInvalidPathChar_ArgumentException(_SEnumerateFilesMethodName);
        }

        [TestMethod]
        public void EnumerateFiles_PathContaisInvalidPathCharSearchPatternNull_ArgumentException()
        {
            //Arrange
            char[] invalidChars = global::System.IO.Path.GetInvalidPathChars();

            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(new string(invalidChars), SStringNull);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFiles_PathContaisInvalidPathCharSearchPatternNullSearchOptionAllDirectories_ArgumentException()
        {
            //Arrange
            char[] invalidChars = global::System.IO.Path.GetInvalidPathChars();

            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(new string(invalidChars), SStringNull, SearchOption.AllDirectories);
            //Act
            ExpectException<ArgumentException>(_SEnumerateFilesMethodName, parameterTypes, parameterValues);
            //Assert
        }

        [TestMethod]
        public void EnumerateFiles_UnknownDirectory_DirectoryNotFoundException()
        {
            PathUnknown_DirectoryNotFoundException(_SEnumerateFilesMethodName, Resources.PathTooLong);
        }

        [TestMethod]
        public void EnumerateFiles_UnknownDirectorySearchPatternEmpty_DirectoryNotFoundException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string>();
            object[] parameterValues = GetValueArray(Resources.PathTooLong, string.Empty);
            //Act
            ExpectException<global::System.IO.DirectoryNotFoundException>(_SEnumerateFilesMethodName, parameterTypes,
                                                                          parameterValues);
            //Assert
        }

        [TestMethod]
        public void
            EnumerateFiles_UnknownDirectorySearchPatternEmptySearchOptionAllDirectories_DirectoryNotFoundException()
        {
            //Arrange
            Type[] parameterTypes = GetTypeArray<string, string, SearchOption>();
            object[] parameterValues = GetValueArray(Resources.PathTooLong, string.Empty, SearchOption.AllDirectories);
            //Act
            ExpectException<global::System.IO.DirectoryNotFoundException>(_SEnumerateFilesMethodName, parameterTypes,
                                                                          parameterValues);
            //Assert
        }
    }
}